package org.grayrabbit.cloud.core.module;

import org.grayrabbit.cloud.core.biz.BizArgument;
import org.grayrabbit.cloud.core.biz.BizChannelModule;
import org.grayrabbit.cloud.core.biz.BizResult;

public class RemoteModule implements Proxy<BizResult, BizArgument> {
	private String moduleName;
	private String remoteAddr;
	private BizChannelModule channel;
	public RemoteModule(String moduleName,String remoteAddr) throws ModuleConstructException{
		this.moduleName = moduleName;
		this.remoteAddr = remoteAddr;
		this.channel = new ServerChannelModule(remoteAddr);
		channel.construct(remoteAddr);
	}
	@Override
	public void construct(String name) throws ModuleConstructException {
	}

	@Override
	public void deconstruct() {
		
	}

	@Override
	public String getName() {
		return moduleName;
	}

	@Override
	public BizResult submit(BizArgument argument) throws ModuleException {
		return (BizResult) channel.submit(argument);//提交远程服务器进行处理
	}

	@Override
	public String getServerName() {
		return remoteAddr;
	}

}
